/*
 * Copyright (c) 2020-2099 the original author or authors. All rights reserve.
 */
package org.tianyun.cloud.config.console.endpoint;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
import org.tianyun.cloud.config.console.ConsoleManager;
import org.tianyun.cloud.config.console.client.response.ConfigRequest;
import org.tianyun.cloud.config.console.client.response.ConfigResponse;

/**
 * 查看控制台属性端点
 *
 * @author ebert_chan
 */
@Endpoint(id = "console-propertys")
public class ConsolePropertysEndpoint {

    private static final Logger log = LoggerFactory.getLogger(ConsolePropertysEndpoint.class);

    @ReadOperation
    public WebEndpointResponse<ConfigResponse> propertys() {
        log.info("Received console property event.");

        ConfigRequest config = ConsoleManager.buildConfig();

        return new WebEndpointResponse<>(config, WebEndpointResponse.STATUS_OK);
    }

}
